import Vue from 'vue'
import Component from 'vue-class-component'
import './messageStyle.css'
import BlankPageClass from '@/components/blankPage.js'

@Component
export default class MessageClass extends Vue {
  messages = []
  canLoad = true
  currentPage = 0
  isLoading = false
  datas = []

  created() {
    this.wrapperHeight = document.documentElement.clientHeight - 121
  }

  async getData() {
    this.currentPage += 1
    if (this.currentPage === 1) {
      this.messages = []
    }
    try {
      let params = {}
      params['pageSize'] = 10
      params['pageIndex'] = this.storeCurrentPage
      const response = await this.$axios.post('/api/v1/messages', params)
      if (response.status === 0) {

      }
    } catch (e) {
      console.log(e)
    }
  }

  loadMore() {

  }

  get caculateHeight() {
    return 'height:' + String(this.wrapperHeight) + 'px'
  }

  createMessageItem() {
    const message = this.messages.map(value => {
      return <div class='messageStyleClass'>
                <h1>这是标题</h1>
                <p>这是副标题</p>
                <p>这是时间</p>
             </div>
    })
    return message
  }

  render () {
    return (
      <div class='content'>
        <mt-header class='header' fixed title="消息">
        </mt-header>
        <BlankPageClass v-show={(this.datas.length <= 0 || !this.datas)}></BlankPageClass>
      </div>
    )
  }
}
